package com.dm0858.bianmin.api;

import com.dm0858.bianmin.model.entity.NewsDetail;
import com.dm0858.bianmin.model.entity.VideoModel;
import com.dm0858.bianmin.model.response.ArticleCatResponse;
import com.dm0858.bianmin.model.response.ArticleDetailResponse;
import com.dm0858.bianmin.model.response.ArticleListResponse;
import com.dm0858.bianmin.model.response.BannerResponse;
import com.dm0858.bianmin.model.response.CommentResponse;
import com.dm0858.bianmin.model.response.IndexNewsListResponse;
import com.dm0858.bianmin.model.response.NewsResponse;
import com.dm0858.bianmin.model.response.NormalResponse;
import com.dm0858.bianmin.model.response.OtherNewsListResponse;
import com.dm0858.bianmin.model.response.RegisterResponse;
import com.dm0858.bianmin.model.response.ResultResponse;
import com.dm0858.bianmin.model.response.SendPhoneCodeResponse;
import com.dm0858.bianmin.model.response.ShangJiaResponse;
import com.dm0858.bianmin.model.response.VideoPathResponse;

import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Url;
import rx.Observable;

/**
 * @author ChayChan
 * @description: 网络请求的service
 * @date 2017/6/18  19:28
 */

public interface ApiService {

    String GET_ARTICLE_LIST = "api/news/feed/v62/?refer=1&count=20&loc_mode=4&device_id=34960436458&iid=13136511752";
    String GET_COMMENT_LIST = "article/v2/tab_comments/";
    //http://is.snssdk.com
    //http://is.snssdk.com/api/news/feed/v54/?refer=1&count=20&min_behot_time=1498722625&last_refresh_sub_entrance_interval=1498724693&loc_mode=4&tt_from=pull（tab_tip） 新闻列表
    //http://is.snssdk.com/article/v2/tab_comments/?group_id=6436886053704958466&item_id=6436886053704958466&offset=30&count=20 评论
    //http://is.snssdk.com/2/article/information/v21/ 详情


    String GET_BANNER = "phpapi/info.php?func=getBanner";
    String GET_NORMALLIST = "phpapi/info.php?func=getClassArticle";

    String GET_SHANGJIA = "phpapi/info.php?func=getArticle";

    String REGISTER = "phpapi/info.php?func=postRegister";

    String GET_INDEXNEWSLIST = "phpapi/info.php?func=getIndexNewsList";

    String GET_ARTICLEDETAIL = "phpapi/info.php?func=getNewsDetail";

    String GET_ARTICLELIST = "phpapi/info.php?func=getNewsList";

    String GET_ARTICLECAT = "phpapi/info.php?func=getNewsCat";

    String GET_OTHERNEWSLIST = "phpapi/info.php?func=getOtherNewsList";

    //获取验证码
    String SEND_PHONE_CODE = "phpapi/info.php?func=sendPhoneCode";
    //手机号码登录/注册
    String PHONE_LOGIN = "phpapi/info.php?func=phoneLogin";
    //微信登录
    String WX_LOGIN = "phpapi/info.php?func=wxLogin";
    //微信绑定手机
    String WX_WITH_PHONE = "phpapi/info.php?func=wxWithPhone";
    //个人信息
    String USER_INFO = "phpapi/info.php?func=userInfo";
    //是否绑定了手机
    String USER_WITH_PHONE = "phpapi/info.php?func=userWithPhone";
    //我的发布
    String USER_ARTICLE = "phpapi/info.php?func=userArticle";
    //获取帖子详情
    String DETAILS_ARTICLE = "phpapi/info.php?func=detailArticle";
    //修改帖子
    String SAVE_ARTICLEC = "phpapi/info.php?func=saveArticlec";
    //删除
    String DEL_ARTICLE = "phpapi/info.php?func=delArticle";
    //上传
    String UPLOAD = "phpapi/bmahoutai/uploadone.php";
    //收藏
    String COLLECT_ARTICLE_ACTION = "phpapi/info.php?func=collectArticleAction";
    //我的收藏
    String USER_COLLECT_ARTICLE = "phpapi/info.php?func=userCollectArticle";
    //平台
    String SYS_UPDATE_TXT = "phpapi/info.php?func=sysUpdateTxt";
    //代理
    String APPLY_AGENT = "phpapi/info.php?func=applyAgent";



    /**
     * 获取新闻列表
     *
     * @param category 频道
     * @return
     */
    @GET(GET_ARTICLE_LIST)
    Observable<NewsResponse> getNewsList(@Query("category") String category, @Query("min_behot_time") long lastTime, @Query("last_refresh_sub_entrance_interval") long currentTime);


    /**
     * 获取新闻详情
     */
    @GET
    Observable<ResultResponse<NewsDetail>> getNewsDetail(@Url String url);

    /**
     * 获取评论列表数据
     *
     * @param groupId
     * @param itemId
     * @param offset
     * @param count
     * @return
     */
    @GET(GET_COMMENT_LIST)
    Observable<CommentResponse> getComment(@Query("group_id") String groupId, @Query(" ") String itemId, @Query("offset") String offset, @Query("count") String count);

    /**
     * 获取视频数据json
     *
     * @param url
     * @return
     */
    @GET
    Observable<ResultResponse<VideoModel>> getVideoData(@Url String url);

    @Headers({
            "Content-Type:application/x-www-form-urlencoded; charset=UTF-8",
            "Cookie:PHPSESSIID=334267171504; _ga=GA1.2.646236375.1499951727; _gid=GA1.2.951962968.1507171739; Hm_lvt_e0a6a4397bcb500e807c5228d70253c8=1507174305;Hm_lpvt_e0a6a4397bcb500e807c5228d70253c8=1507174305; _gat=1",
            "Origin:http://toutiao.iiilab.com"

    })
    @POST("http://service.iiilab.com/video/toutiao")
    Observable<VideoPathResponse> getVideoPath(@Query("link") String link,@Query("r") String r,@Query("s") String s);


    /**
     * 获取banner图
     *
     * @return
     */
    @GET(GET_BANNER)
    Observable<BannerResponse> getBanner();




    /**
     * 获取普通信息列表
     *
     * @return
     */
    @GET(GET_NORMALLIST)
    Observable<NormalResponse> getNormalList(@Query("classid") String classid,@Query("area") String area,@Query("lat") String lat,@Query("lng") String lng);


    /**
     * 获取商家详情
     *
     * @return
     */
    @GET(GET_SHANGJIA)
    Observable<ShangJiaResponse> getShangJia(@Query("tid") String tid,@Query("userid") String userid);


    /**
     * 注册
     *
     * @return
     */
    @FormUrlEncoded
    @POST(REGISTER)
    Observable<RegisterResponse> postRegister(@Field("account") String account,@Field("pwd") String pwd);


    /**
     * 获取banner图
     *
     * @return
     */
    @GET(GET_INDEXNEWSLIST)
    Observable<IndexNewsListResponse> getIndexNewsList();


    /**
     * 获取新闻详情
     *
     * @return
     */
    @GET(GET_ARTICLEDETAIL)
    Observable<ArticleDetailResponse> getArticleDetail(@Query("id") String tid);


    /**
     * 获取新闻列表
     *
     * @return
     */
    @GET(GET_ARTICLELIST)
    Observable<ArticleListResponse> getArticleList(@Query("catid") String catid,@Query("page") String page);


    /**
     * 获取新闻分类
     *
     * @return
     */
    @GET(GET_ARTICLECAT)
    Observable<ArticleCatResponse> getArticleCat();


    /**
     * 获取其他新闻
     *
     * @return
     */
    @GET(GET_OTHERNEWSLIST)
    Observable<OtherNewsListResponse> getOtherNewsList(@Query("type") String type);


    @POST(SEND_PHONE_CODE)
    Observable<SendPhoneCodeResponse> sendPhoneCode(@Body RequestBody requestBody);

}

